const mongoose = require('mongoose')
const db = 'mongodb://127.0.0.1/ehentai'
const Schema = mongoose.Schema

mongoose.connect(db, {
  server: { poolSize: 20 }
}, function (err) {
  console.log('数据库连接成功...')
  if (err) {
    process.exit(1)
  }
})

const UsersSchema = new Schema({
  username: {type: String, required: true, unique: true},
  password: {type: String, required: true},
  avatar: {type: String, required: true}
})

const Models = {
  UsersModel: mongoose.model('User', UsersSchema, 'users')
}

module.exports = Models
